export default eventHandler(async (event) => {
  const body = await readBody(event)
  const required = ['userName', 'userCompany', 'userPassword', 'confirmPassword', 'userPhone', 'verificationcode']
  for (const key of required) {
    if (!body?.[key])
      return sendError(event, createError({ statusCode: 400, statusMessage: `${key} is required` }))
  }
  if (body.userPassword !== body.confirmPassword)
    return sendError(event, createError({ statusCode: 400, statusMessage: 'Passwords do not match' }))
  if (body.verificationcode !== '654321')
    return sendError(event, createError({ statusCode: 400, statusMessage: 'Invalid verification code' }))

  return { 
    code: 0, 
    message: "OK", 
    data: { 
      userName: body.userName, 
      userCompany: body.userCompany, 
      userPhone: body.userPhone 
    } 
  }
})

